package com.qianfeng.openplatform.geteway.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

/**
 * @author 江江
 * @Date 2020/7/23 20:44
 */
@FeignClient("OPENAPI-CACHE")
public interface CacheClient {
    @RequestMapping("/cache/save2Redis")
    public boolean save2Redis(@RequestParam String key, @RequestParam String value, @RequestParam Long expireTime) throws Exception;

    @RequestMapping("/cache/getFromRedis/{key}")
    public String getFromRedis(@PathVariable String key) throws Exception;

    @RequestMapping("/cache/deleteKey/{key}")
    public boolean deleteKey(@PathVariable String key) throws Exception;

    @RequestMapping("/cache/expire/{key}/{expireTime}")
    public boolean expire(@PathVariable String key, @PathVariable long expireTime) throws Exception;


    @RequestMapping("/cache/smembers/{key}")
    public Set<Object> sMembers(@PathVariable String key) throws Exception;

    @RequestMapping("/cache/sadd")
    public Long sAdd(@RequestParam String key,@RequestParam  String value,@RequestParam  Long expireTime) throws Exception;

    @RequestMapping("/cache/saddAll")
    public Long sAdd(@RequestParam String key, @RequestBody String[] value, @RequestParam  Long expireTime) throws Exception;


    @RequestMapping("/sremove/{key}/{value}")
    public Long sRemove(@PathVariable String key,@PathVariable String value) throws Exception;

    @RequestMapping("/cache/findKeyByPartten/{partten}")
    public Set<String> findKeyByPartten(@PathVariable String partten) throws Exception;

    @RequestMapping(value = "/cache/hgetall",method = RequestMethod.GET)
    public Map<Object, Object> hGetAll(@RequestParam String key) throws Exception;

    @RequestMapping(value = "/cache/hmset",method = RequestMethod.POST)
    public boolean hMset(@RequestParam String key,@RequestBody Map<Object,Object> map) throws Exception;

    @RequestMapping(value = "/cache/hmset",method = RequestMethod.POST)
    public boolean hMset(@RequestParam String key,@RequestBody Object obj) throws Exception;

    @RequestMapping("/cache/hget/{key}/{field}")
    public String hGet(@PathVariable String key, @PathVariable String field) throws Exception;

    @RequestMapping(value = "/cache/hIncrement/{key}/{field}/{delta}")
    public Long hIncrement(@PathVariable String key,@PathVariable String field,@PathVariable long delta) throws Exception;
}
